// TcTaskBarIcon.cs
//
//  Copyright (C) 2008 Jacek Trubłajewicz
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
//

using System;

namespace NewTcGui
{
	public class TcTaskBarIcon: wx.TaskBarIcon
	{
		private enum Id 
		{     
			PU_RESTORE = 10001, 
			PU_NEW_ICON, 
			PU_EXIT, 
		}
		
		private wx.Window parent;
		
		public TcTaskBarIcon(wx.Window parent)
		{
			this.parent = parent;
			
			EVT_TASKBAR_LEFT_DOWN(new wx.EventListener(OnLeftDown));
			EVT_MENU((int) Id.PU_RESTORE, new wx.EventListener(OnRestoreClicked));
		}
		
		protected void OnLeftDown(object sender, wx.Event evt)
		{
			System.Console.WriteLine("task bar icon click");
			if(parent.IsShown)
			{
				parent.Show(false);
			}
			else
				parent.Show(true);
		}
		
		public override wx.Menu CreatePopupMenu()
		{
			wx.Menu popupMenu = new wx.Menu();
			popupMenu.Append((int) Id.PU_RESTORE, "&Restore TBTest");     
			popupMenu.Append((int) Id.PU_NEW_ICON, "&Set New Icon"); 
			popupMenu.Append((int) Id.PU_EXIT,    "E&xit"); 
			return popupMenu; 
		}
		
		protected void OnRestoreClicked(object sender, wx.Event evt)
		{
			parent.Show(true);
		}

	}
}
